from celery_tasks.celery import app
from meiduo_mall.libs.yuntongxun.sms import CCP


@app.task(bind=True)
def send_message(self, mobile, sms_code):
    # 测试耗时
    import time
    time.sleep(10)

    # 1, 发送短信
    try:
        result = CCP().send_template_sms(mobile, [sms_code, 5], 1)
        print(result)
    except Exception as e:
        result = -1

    # if result == -1:
    #     self.retry(exc=Exception('发送短信失败'), countdown=5, max_retries=5)